Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

322
Vistas
How to solve "TypeError: $(...).length is not a function"?

My code is like this :

$(document).ready(function () {
    size_li = $("#myList li").length();
    x=3;
    $('#myList li:lt('+x+')').show();
    $('#loadMore').click(function () {
        x= (x+5 <= size_li) ? x+5 : size_li;
        $('#myList li:lt('+x+')').show();
    });
    $('#showLess').click(function () {
        x=(x-5<0) ? 3 : x-5;
        $('#myList li').not(':lt('+x+')').hide();
    });
});

Or see demo and full code here : http://jsfiddle.net/oscar11/6FzSb/4177/

I use jquery 3.0.1

When executed, there exist error :

TypeError: $(...).length is not a function

How can I solve it?

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Instead of this

$("#myList li").length();

Use this:

$("#myList li").length;

The $("#myList li") returns an array like object. All array like objects have a property called length, which when be read returns the number of items contained in the array like object. That being said there isn't any function called length. Hence length() is meaningless.

over 4 years ago · Santiago Trujillo Denunciar

0

length is a property, not a function, so remove the ()

$("#myList li").length;
over 4 years ago · Santiago Trujillo Denunciar

0

length is not a function it is just Yourthings.length without (). more doc at length documentation

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda